package com.component.api.model.data;

import com.component.api.model.AbstractData;
import com.component.api.model.DataType;
import com.component.api.model.param.TableColumn;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 描述：
 * 列传递对象
 * @author xianggj
 * @Date 2021/12/1 10:46
 **/
@Data
@NoArgsConstructor
public class ColumnData extends AbstractData {
    private static final long serialVersionUID = -1;
    /**
     * 列数据
     */
    protected List<TableColumn> columns;

    public ColumnData(List<TableColumn> columns) {
        this.columns = columns;
    }

    public ColumnData(DataType type) {
        super(type);
    }

    public ColumnData(DataType type, List<TableColumn> columns) {
        super(type);
        this.columns = columns;
    }


    public List<String> getColName(){
        if (columns == null){
            return new ArrayList<>();
        }
        return columns.stream().map(e->e.getColumnName()).collect(Collectors.toList());

    }
}
